import {Direction, Point} from "../../../nodeApp/static/lib/crowncad-plugin-sdk-0.0.1";
import {beltDriveModelCommand} from "./BeltDriveModelCommand";

class FlatBeltDriveCommand{
  query = null;
  command = null;
  pointList = [];
  deep = 0;
  radian = 0;
  beltPointList = [];
  constructor(query, command, pointList, deep, radian) {
    this.query = query;
    this.command = command;
    this.pointList = pointList;
    this.deep = deep;
    this.radian = radian;
  }

  //创建轮
  async createFlatWheel(beltDriveParams, no, type){
    if(type === 1) {
      let L = beltDriveParams.paramsWheel1.L;
      let B = beltDriveParams.paramsWheel1.B;
      if(L > B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType1) {
          case 'solidWheelType':
            result = await this.createSolidDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, true, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, true, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createOrificeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, numHole, true, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createOrificeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, numHole, true, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createFourOvalSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, true, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createSixOvalSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, true, no);
            break;
          default:
            break;
        }
        return result;
      } else if(L <= B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType1) {
          case 'solidWheelType':
            result = await this.createSolidDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, false, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, false, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createOrificeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, numHole, false, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createOrificeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, numHole, false, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createFourOvalSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, false, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createSixOvalSpokeDrivingWheel(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, false, no);
            break;
          default:
            break;
        }
        return result;
      }
    } else if(type === 2) {
      let L = beltDriveParams.paramsWheel2.L;
      let B = beltDriveParams.paramsWheel2.B;
      if(L > B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType2) {
          case 'solidWheelType':
            result = await this.createSolidDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, true, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, true, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createOrificeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, numHole, true, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createOrificeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, numHole, true, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createFourOvalSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, true, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createSixOvalSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, true, no);
            break;
          default:
            break;
        }
        return result;
      } else if(L <= B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType2) {
          case 'solidWheelType':
            result = await this.createSolidDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, false, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, false, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createOrificeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, numHole, false, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createOrificeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, numHole, false, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createFourOvalSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, false, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createSixOvalSpokeDrivenWheel(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, false, no);
            break;
          default:
            break;
        }
        return result;
      }
    }
  }

  //创建带
  async createFlatBelt(beltDriveParams, sketchNumber) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    /*带*/
    //创建基准面2、3、4、5
    let sketchDatumFeature = await beltDriveModelCommand.creatLoftSketchDatum(datum, this.pointList);

    //创建基准面草图1
    let sketchFeature1 = await flatBeltDriveCommand.createAddFlatBeltSketch(sketchDatumFeature[0], beltDriveParams, parseFloat(beltDriveParams.singleBeltThickness), 0, 1, sketchNumber++);
    if(!sketchFeature1) {
      return;
    }
    sketchNumber = sketchFeature1.no;
    //创建基准面草图2
    let sketchFeature2 = await flatBeltDriveCommand.createAddFlatBeltSketch(sketchDatumFeature[1], beltDriveParams, parseFloat(beltDriveParams.singleBeltThickness), 0, 2, sketchNumber++);
    if(!sketchFeature2) {
      return;
    }
    sketchNumber = sketchFeature2.no;
    //创建基准面草图3
    let sketchFeature3 = await flatBeltDriveCommand.createAddFlatBeltSketch(sketchDatumFeature[2], beltDriveParams, parseFloat(beltDriveParams.singleBeltThickness), 0, 1, sketchNumber++);

    //上直线拉伸基体
    let direction1 = new Direction();
    direction1.setPoint(new Point(this.pointList[0].inPoints[0].x, this.pointList[0].inPoints[0].y, 0), new Point(this.pointList[0].inPoints[2].x, this.pointList[0].inPoints[2].y, 0));
    let dis1 = Math.sqrt(Math.pow(this.pointList[0].inPoints[0].x - this.pointList[0].inPoints[2].x, 2) + Math.pow(this.pointList[0].inPoints[0].y - this.pointList[0].inPoints[2].y, 2));
    for(let i = 0; i < sketchFeature1.sketchFeatures?.length; i++) {
      let extrudeFeature1 = await beltDriveModelCommand.extrudeWithDirectionAddendum(query, solid, sketchFeature1.sketchFeatures[i], direction1, 0, dis1);
    }
    //下直线拉伸基体
    let direction2 = new Direction();
    direction2.setPoint(new Point(this.pointList[0].inPoints[1].x, this.pointList[0].inPoints[1].y, 0), new Point(this.pointList[0].inPoints[3].x, this.pointList[0].inPoints[3].y, 0));
    let dis2 = dis1;
    for(let i = 0; i < sketchFeature2.sketchFeatures?.length; i++) {
      let extrudeFeature2 = await beltDriveModelCommand.extrudeWithDirectionAddendum(query, solid, sketchFeature2.sketchFeatures[i], direction2, 0, dis2);
    }
    //主动轮旋转基体
    for(let i = 0; i < sketchFeature1.sketchFeatures?.length; i++) {
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1.sketchFeatures[i], beltDriveParams, 0, 360 - (this.radian / Math.PI) * 360, 1);
    }
    //从动轮旋转基体
    for(let i = 0; i < sketchFeature3.sketchFeatures?.length; i++) {
      let extrudeFeature2 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature3.sketchFeatures[i], beltDriveParams, 1, this.radian / Math.PI * 360, 2);
    }
  }

  /**************************************************
   * 平带轮驱动命令Start
   * *************************************************/
  /*实心轮建模Start*/
  async createSolidDrivingWheel(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let sketch = this.command.sketch;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSolidWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSolidWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 5, 0);
    

    return {feature: extrudeCutFeature1, no: no};
  }

  async createSolidDrivenWheel(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSolidWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSolidWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 5, 0);

      return {feature: extrudeCutFeature1, no: no};
    }
  }
  /*实心轮建模End*/

  /*辐板轮建模Start*/
  async createSpokeDrivingWheel(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);

    return {feature: extrudeCutFeature1, no: no};
  }
  async createSpokeDrivenWheel(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);

      return {feature: extrudeCutFeature1, no: no};
    }
  }
  /*辐板轮建模End*/

  /*孔板轮建模Start*/
  //L>B
  async createOrificeDrivingWheel(beltDriveParams, solidWheel, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let datumId = 22;
    if(numHole === 6) {
      datumId = 36;
    }
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建草图3
    let sketchFeature3 = null;
    if(numHole === 4) {
      sketchFeature3 = await this.createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, 0, numHole, datumId, no++);
    }else if(numHole === 6) {
      sketchFeature3 = await this.createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, 0, numHole, datumId, no++);
    }
    
    //计算旋转轴y
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let delta = 0.005 * d + 3;
    let R1 = D1 / 2;
    let axisX = 0;
    let axisY = 0;
    if(numHole === 4) {
      let holeD = (d - D1) / 2 - h - delta - S;
      let holeR = holeD / 2;
      axisX = 0;
      axisY = R1 + S/2 + holeR;

    } else if(numHole === 6) {
      let diffDeltaD1 = (d - D1) / 2 - delta - h;
      let halfDiffDeltaD1R = R1 + diffDeltaD1 / 2;
      axisX = halfDiffDeltaD1R;
      axisY = 0;
    }
    //旋转切除1
    let revolveCutFeature1 = await beltDriveModelCommand.revolveCutAuxiliary(query, solid, sketchFeature3, extrudeCutFeature1, beltDriveParams, axisX, axisY, 0, 360, 1);
    
    //圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, revolveCutFeature1, beltDriveParams, numHole, 1);
    

    return {feature: circularFeature1, no: no};
  }
  async createOrificeDrivenWheel(beltDriveParams, solidWheel, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建草图3
      if(numHole === 6) {
        datumId = 36;
      }
      //创建草图3
      let sketchFeature3 = null;
      if(numHole === 4) {
        sketchFeature3 = await this.createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, parseFloat(beltDriveParams.distance), numHole, datumId, no++);
      }else if(numHole === 6) {
        sketchFeature3 = await this.createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, parseFloat(beltDriveParams.distance), numHole, datumId, no++);
      }
      
      //计算旋转轴y
      let S = parseFloat(solidWheel.S);
      let D1 = parseFloat(solidWheel.D1);
      let d = parseFloat(solidWheel.d);
      let h = parseFloat(solidWheel.h);
      let delta = 0.005 * d + 3;
      let R1 = D1 / 2;
      let holeD = (d - D1) / 2 - h - delta - S;
      let holeR = holeD / 2;
      let axisY = R1 + S / 2 + holeR;
      let axisX = 0;
      if(numHole === 4) {
        axisX = 0;
        axisY = axisY;
      } else if(numHole === 6) {
        axisX = axisY;
        axisY = 0;
      }
      //旋转切除1
      let revolveCutFeature1 = await beltDriveModelCommand.revolveCutAuxiliary(query, solid, sketchFeature3, extrudeCutFeature1, beltDriveParams, axisX, axisY, 0, 360, 2);
      //圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, revolveCutFeature1, beltDriveParams, numHole, 2);

      return {feature: circularFeature1, no: no};
    }
  }
  /*孔板轮建模End*/

  /*四椭圆辐轮建模Start*/
  //L>B
  async createFourOvalSpokeDrivingWheel(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建带轮草图3
    let sketchFeature3 = await this.createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, 0, n, numHole, no++);
    if(!sketchFeature3) {
      return {feature: extrudeCutFeature1, no: no};
    }
    //创建带轮草图3的拉伸切除
    let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
    //创建带轮圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 1);// 创建圆周阵列1

    return {feature: circularFeature1, no: no};
  }
  async createFourOvalSpokeDrivenWheel(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid,sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建带轮草图3
      let sketchFeature3 = await this.createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, beltDriveParams.distance, n, numHole, no++);
      if(!sketchFeature3) {
        return {feature: extrudeCutFeature1, no: no};
      }
      //创建带轮草图3的拉伸切除
      let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
      //创建带轮圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 2);

      return {feature: circularFeature1, no: no};
    }
  }
  /*四椭圆辐轮建模End*/

  /*六椭圆辐轮建模Start*/
  //L>B
  async createSixOvalSpokeDrivingWheel(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid,sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建带轮草图3
    let sketchFeature3 = await this.createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, 0, n, numHole, no++);
    //创建带轮草图3的拉伸切除
    let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
    //创建带轮圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 1);// 创建圆周阵列1

    return {feature: circularFeature1, no: no};
  }
  async createSixOvalSpokeDrivenWheel(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建带轮草图3
      let sketchFeature3 = await this.createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, beltDriveParams.distance, n, numHole, no++);
      //创建带轮草图3的拉伸切除
      let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
      //创建带轮圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 2);// 创建圆周阵列1

      return {feature: circularFeature1, no: no};
    }
  }
  /*六椭圆辐轮建模End*/
  /**************************************************
   * 平带轮驱动命令End
   * *************************************************/


  /**************************************************
   * 平带传动实现函数Start
   * *************************************************/
  /*带*/
  async createAddBeltSketch(sketchDatumFeature, beltDriveParams, singleBeltThickness, startNumber) {
    let query = this.query;
    let command = this.command;
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {

      let entityId = datumEntities[0]?.id;
      let points = this.pointList;

      //let singleBeltThickness = parseFloat(beltDriveParams.singleBeltThickness);
      let radius1 = parseFloat(beltDriveParams.diameter1) / 2;
      let radius2 = parseFloat(beltDriveParams.diameter2) / 2;
      let distance = parseFloat(beltDriveParams.distance);

      let sketchFeatures = [];
      for (let i = 0; i < points.length; i++) {
        let number = i + startNumber;
        sketch.createSketch({sketchName: '草图' + number.toString(), datumId: entityId});

        //内圈
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].inPoints[0].x, points[i].inPoints[0].y),
          secondPoint: new Point(points[i].inPoints[1].x, points[i].inPoints[1].y),
          thirdPoint: new Point(-radius1 - (singleBeltThickness * i) + this.deep, 0)
        });
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].inPoints[2].x, points[i].inPoints[2].y),
          secondPoint: new Point(points[i].inPoints[3].x, points[i].inPoints[3].y),
          thirdPoint: new Point(distance + radius2 + (singleBeltThickness * i) - this.deep, 0)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].inPoints[0].x, points[i].inPoints[0].y),
          endPoint: new Point(points[i].inPoints[2].x, points[i].inPoints[2].y)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].inPoints[1].x, points[i].inPoints[1].y),
          endPoint: new Point(points[i].inPoints[3].x, points[i].inPoints[3].y)
        });

        //外圈
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].outPoints[0].x, points[i].outPoints[0].y),
          secondPoint: new Point(points[i].outPoints[1].x, points[i].outPoints[1].y),
          thirdPoint: new Point(-radius1 - (singleBeltThickness * (i + 1)) + this.deep, 0)
        });
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].outPoints[2].x, points[i].outPoints[2].y),
          secondPoint: new Point(points[i].outPoints[3].x, points[i].outPoints[3].y),
          thirdPoint: new Point(distance + radius2 + (singleBeltThickness * (i + 1)) - this.deep, 0)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].outPoints[0].x, points[i].outPoints[0].y),
          endPoint: new Point(points[i].outPoints[2].x, points[i].outPoints[2].y)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].outPoints[1].x, points[i].outPoints[1].y),
          endPoint: new Point(points[i].outPoints[3].x, points[i].outPoints[3].y)
        });

        sketch.exitSketch();

        let res = await command.executeIncrementCommand(command.commandScript);
        command.clearCommand();
        let currentFeature = res?.data?.modelData?.currentFeature;
        if (currentFeature && currentFeature.length > 0) {
          let sketchFeature = {
            id: currentFeature[0]?.id,
            name: currentFeature[0]?.name,
          }
          sketchFeatures.push(sketchFeature);
        }
      }
      return sketchFeatures;
    }
  }

  /*带*/
  async createAddFlatBeltSketch(sketchDatumFeature, beltDriveParams, singleBeltThickness, index, type, startNumber) {
    let query = this.query;
    let command = this.command;
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }

    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {

      let entityId = datumEntities[0]?.id;
      let sketchFeatures = [];
      for (let i = 0; i < beltDriveParams.beltCount; i++) {
        let number = i + startNumber;
        sketch.createSketch({sketchName: '草图' + number.toString(), datumId: entityId});

        // //内圈
        // let innerPnt0 = new Point(this.beltPointList[0].Points[0].x, this.beltPointList[0].Points[0].y + singleBeltThickness * i);
        // let innerPnt1 = new Point(this.beltPointList[0].Points[1].x, this.beltPointList[0].Points[1].y + singleBeltThickness * i);
        // let innerPnt2 = new Point(this.beltPointList[0].Points[2].x, this.beltPointList[0].Points[2].y + singleBeltThickness * i);
        // let innerPnt3 = new Point(this.beltPointList[0].Points[3].x, this.beltPointList[0].Points[3].y + singleBeltThickness * i);
        //
        // //外圈
        // let outerPnt0 = new Point(this.beltPointList[0].Points[0].x, this.beltPointList[0].Points[0].y + singleBeltThickness * (i + 1));
        // let outerPnt1 = new Point(this.beltPointList[0].Points[1].x, this.beltPointList[0].Points[1].y + singleBeltThickness * (i + 1));
        // let outerPnt2 = new Point(this.beltPointList[0].Points[2].x, this.beltPointList[0].Points[2].y + singleBeltThickness * (i + 1));
        // let outerPnt3 = new Point(this.beltPointList[0].Points[3].x, this.beltPointList[0].Points[3].y + singleBeltThickness * (i + 1));

        // //内圈
        let innerPnt0 = new Point(this.beltPointList[index].Points[0].x, this.beltPointList[0].Points[0].y + singleBeltThickness * i);
        let innerPnt1 = new Point(this.beltPointList[index].Points[1].x, this.beltPointList[0].Points[1].y + singleBeltThickness * i);
        let innerPnt2 = new Point(this.beltPointList[index].Points[2].x, this.beltPointList[0].Points[2].y + singleBeltThickness * i);
        let innerPnt3 = new Point(this.beltPointList[index].Points[3].x, this.beltPointList[0].Points[3].y + singleBeltThickness * i);
        let innerPnt4 = new Point(this.beltPointList[index].Points[4].x, this.beltPointList[0].Points[4].y + singleBeltThickness * i);
        let innerPnt5 = new Point(this.beltPointList[index].Points[5].x, this.beltPointList[0].Points[5].y + singleBeltThickness * i);

        //外圈
        let outerPnt0 = new Point(this.beltPointList[index].Points[0].x, this.beltPointList[0].Points[0].y + singleBeltThickness * (i + 1));
        let outerPnt1 = new Point(this.beltPointList[index].Points[1].x, this.beltPointList[0].Points[1].y + singleBeltThickness * (i + 1));
        let outerPnt2 = new Point(this.beltPointList[index].Points[2].x, this.beltPointList[0].Points[2].y + singleBeltThickness * (i + 1));
        let outerPnt3 = new Point(this.beltPointList[index].Points[3].x, this.beltPointList[0].Points[3].y + singleBeltThickness * (i + 1));
        let outerPnt4 = new Point(this.beltPointList[index].Points[4].x, this.beltPointList[0].Points[4].y + singleBeltThickness * (i + 1));
        let outerPnt5 = new Point(this.beltPointList[index].Points[5].x, this.beltPointList[0].Points[5].y + singleBeltThickness * (i + 1));

        if(type === 2) {
          innerPnt0.x = -innerPnt0.x;
          innerPnt0.y = -innerPnt0.y;
          innerPnt1.x = -innerPnt1.x;
          innerPnt1.y = -innerPnt1.y;
          innerPnt2.x = -innerPnt2.x;
          innerPnt2.y = -innerPnt2.y;
          innerPnt3.x = -innerPnt3.x;
          innerPnt3.y = -innerPnt3.y;
          innerPnt4.x = -innerPnt4.x;
          innerPnt4.y = -innerPnt4.y;
          innerPnt5.x = -innerPnt5.x;
          innerPnt5.y = -innerPnt5.y;

          outerPnt0.x = -outerPnt0.x;
          outerPnt0.y = -outerPnt0.y;
          outerPnt1.x = -outerPnt1.x;
          outerPnt1.y = -outerPnt1.y;
          outerPnt2.x = -outerPnt2.x;
          outerPnt2.y = -outerPnt2.y;
          outerPnt3.x = -outerPnt3.x;
          outerPnt3.y = -outerPnt3.y;
          outerPnt4.x = -outerPnt4.x;
          outerPnt4.y = -outerPnt4.y;
          outerPnt5.x = -outerPnt5.x;
          outerPnt5.y = -outerPnt5.y
        }
        sketch.createArcByThreePoint({
          firstPoint: innerPnt0,
          secondPoint: innerPnt2,
          thirdPoint: innerPnt1
        });
        sketch.createSketchLine({
          startPoint: innerPnt2,
          endPoint: innerPnt3
        });
        sketch.createArcByThreePoint({
          firstPoint: innerPnt3,
          secondPoint: innerPnt5,
          thirdPoint: innerPnt4
        });
        sketch.createSketchLine({
          startPoint: innerPnt0,
          endPoint: outerPnt0
        });
        sketch.createArcByThreePoint({
          firstPoint: outerPnt0,
          secondPoint: outerPnt2,
          thirdPoint: outerPnt1
        });
        sketch.createSketchLine({
          startPoint: outerPnt2,
          endPoint: outerPnt3
        });
        sketch.createArcByThreePoint({
          firstPoint: outerPnt3,
          secondPoint: outerPnt5,
          thirdPoint: outerPnt4
        });
        sketch.createSketchLine({
          startPoint: outerPnt5,
          endPoint: innerPnt5
        });

        sketch.exitSketch();

        let res = await command.executeIncrementCommand(command.commandScript);
        command.clearCommand();
        let currentFeature = res?.data?.modelData?.currentFeature;
        if (currentFeature && currentFeature.length > 0) {
          let sketchFeature = {
            id: currentFeature[0]?.id,
            name: currentFeature[0]?.name,
          }
          sketchFeatures.push(sketchFeature);
        }
      }
      return {
        sketchFeatures: sketchFeatures,
        no: startNumber + parseFloat(beltDriveParams.beltCount)
      }
    }
  }

  /*实心轮*/
  //L>B
  async createAddSolidWheelSketchType1(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b = parseFloat(beltDriveParams.beltWidth);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let diffLB = L - B;
    let solidBotY = ((D1 - D) / 2);
    let leftX = 0.24 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    //let r1 = 0.05 * L;
    let r1 = 0.4 * solidBotY;
    let radian1 = (45 / 180) * Math.PI;

    let leftBotPnt = new Point(-L, D/2);
    let leftMidLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidRightPnt = new Point(leftBotPnt.x + (L - B), leftMidLeftPnt.y);
    let leftTopPnt = new Point(leftMidRightPnt.x, leftMidLeftPnt.y + ((d - D1)/2 - h));
    let rightTopPnt = new Point(0, d/2 - h);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    let rightBotPnt = new Point(0, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidLeftPnt1 = new Point(leftMidLeftPnt.x, leftMidLeftPnt.y - leftY);
    let leftMidLeftPnt2 = new Point(leftMidLeftPnt.x + leftX, leftMidLeftPnt.y);
    //左边中心位置圆弧点
    let leftMidRightPnt1 = new Point(leftMidRightPnt.x - r1, leftMidRightPnt.y);
    let leftMidRightPnt2 = new Point(leftMidRightPnt.x, leftMidRightPnt.y + r1);
    let leftMidRightPnt3 = new Point((leftMidRightPnt.x - r1) + r1 * Math.cos(radian1), (leftMidRightPnt.y + r1) - r1 * Math.sin(radian1));
    // let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y - topDiffY);
    // let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y - topDiffY);
    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidLeftPnt1, endPoint: leftMidLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidLeftPnt2, endPoint: leftMidRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidRightPnt1, secondPoint: leftMidRightPnt2, thirdPoint:leftMidRightPnt3 });
    sketch.createSketchLine({startPoint: leftMidRightPnt2, endPoint: leftTopPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  async createAddWheelCutSketch(beltDriveParams, solidWheel, dis, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let L = parseFloat(solidWheel.L);
    let B = parseFloat(solidWheel.B);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let R = D / 2;
    let R1 = D1 / 2;
    let diffLB = Math.abs(L - B);
    let solidBotY = (D1 - D) / 2;
    let outX = parseFloat(dis) + R + 0.35 * solidBotY;
    let radian = (10 / 180) * Math.PI;
    let inX = parseFloat(dis) + R * Math.cos(radian);
    let inY = R * Math.sin(radian);

    let point1 = new Point(inX, inY);
    let point2 = new Point(outX, inY);
    let point3 = new Point(outX, -inY);
    let point4 = new Point(inX, -inY);

    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createSketchLine({startPoint: point2, endPoint: point3});
    sketch.createSketchLine({startPoint: point3, endPoint: point4});
    sketch.createSketchLine({startPoint: point4, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSolidWheelSketchType2(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b = parseFloat(beltDriveParams.beltWidth);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let delta = 0.005 * d + 3;
    let diffLB = B - L;
    let solidBotY = ((D1 - D) / 2);
    let leftX = 0.2 * delta;
    let leftY = 0.2 * delta;
    let midX = 0.24 * solidBotY;
    let midY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    //let r1 = 0.05 * L;
    let radian = Math.atan(1 / 25);
    let slopeY = (diffLB - leftX) * Math.tan(radian);

    let leftBotPnt = new Point(-L, D/2);
    let leftMidLeftPnt = new Point(-B, d/2 - h - delta);
    let leftMidRightPnt = new Point(-L, leftMidLeftPnt.y - slopeY);
    let leftTopPnt = new Point(-B, d/2 - h);
    let rightTopPnt = new Point(0, d/2 - h);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    let rightBotPnt = new Point(0, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    let leftBotPnt1 = new Point(leftBotPnt.x + midX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + midY);
    let leftMidLeftPnt1 = new Point(leftMidLeftPnt.x + leftX, leftMidLeftPnt.y);
    let leftMidLeftPnt2 = new Point(leftMidLeftPnt.x, leftMidLeftPnt.y + leftY);
    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);


    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidRightPnt});
    sketch.createSketchLine({startPoint: leftMidRightPnt, endPoint: leftMidLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidLeftPnt1, endPoint: leftMidLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidLeftPnt2, endPoint: leftTopPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  /*辐板轮*/
  //L>B
  async createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b = parseFloat(beltDriveParams.beltWidth);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let S = parseFloat(solidWheel.S);
    let delta = 0.005 * d + 3;
    let diffLB = (L - B) / 2;
    let hollowY = (d - D1) / 2 - h - delta;
    let solidBotY = ((D1 - D) / 2);

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.25 * solidBotY;
    let rightY = 0.25 * solidBotY;
    let topX = 0.2 * delta;
    let topY = 0.2 * delta;
    //let innerX = 0.1 * solidBotY;
    //let innerY = 0.1 * solidBotY;
    let diffInner1 = 0.8 * 0.5 * S;
    let diffInner2 = 0.1 * solidBotY;
    let diffInner = diffInner1;
    if(diffInner1 > diffInner2) {
      diffInner = diffInner2;
    }
    let innerX = diffInner;
    let innerY = diffInner;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotY = ((L - S) / 2  - leftX - innerX) * Math.tan(radian);
    let slopeTopY = ((B - S) / 2  - topX - innerX) * Math.tan(radian);
    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-L + diffLB, D/2);
    let leftMidBotLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidBotRightPnt = new Point(leftMidBotLeftPnt.x + ((L-S)/2), leftMidBotLeftPnt.y + slopeBotY);
    let leftMidTopRightPnt = new Point(leftMidBotRightPnt.x, d/2 - h - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - h - delta);
    //上边定位点
    let leftTopPnt = new Point(leftMidTopLeftPnt.x, d/2 - h);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    // let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, leftTopPnt.y + h);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-(B-S)/2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(rightMidTopleftPnt.x, leftMidBotLeftPnt.y + slopeBotY);
    let rightMidBotRightPnt = new Point(diffLB, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y - leftY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + leftX, leftMidBotLeftPnt.y);

    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y);
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt3 = new Point(leftMidBotRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidBotRightPntArcCenter.y - innerR * Math.sin(radian1));

    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y);
    let leftMidTopRightPnt3 = new Point(leftMidTopRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidTopRightPntArcCenter.y + innerR * Math.sin(radian1));

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y);
    let rightMidBotLeftPnt3 = new Point(rightMidBotLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidBotLeftPntArcCenter.y - innerR * Math.sin(radian1));

    let rightMidTopLeftPntArcCenter = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y);
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt3 = new Point(rightMidTopLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidTopLeftPntArcCenter.y + innerR * Math.sin(radian1));

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidBotRightPnt1, secondPoint: leftMidBotRightPnt2, thirdPoint: leftMidBotRightPnt3});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidTopRightPnt1, secondPoint: leftMidTopRightPnt2, thirdPoint: leftMidTopRightPnt3});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidTopLeftPnt1, secondPoint: rightMidTopLeftPnt2, thirdPoint: rightMidTopLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidBotLeftPnt1, secondPoint: rightMidBotLeftPnt2, thirdPoint: rightMidBotLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b = parseFloat(beltDriveParams.beltWidth);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let S = parseFloat(solidWheel.S);
    let delta = 0.005 * d + 3;
    let diffB = (B - S) / 2;
    //let diffL = L - (diffB + S);
    //if(diffL <= 0) {
      //L = 0.9 * B;
      //diffL = L - (diffB + S);
    //}
    let diffLLeft = 0.7 * L;
    let diffLRight = 0.3 * L;
    let solidBotY = (D1 - D) / 2;

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let topX = 0.2 * delta;
    let topY = 0.2 * delta;
    // let innerX = 0.1 * solidBotY;
    // let innerY = 0.1 * solidBotY;
    let diffInner1 = 0.8 * 0.5 * S;
    let diffInner2 = 0.1 * solidBotY;
    let diffInner = diffInner1;
    if(diffInner1 > diffInner2) {
      diffInner = diffInner2;
    }
    let innerX = diffInner;
    let innerY = diffInner;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = (diffLLeft - S/2 - leftX - innerX) * Math.tan(radian);
    let slopeTopLeftY = (diffB - topX - innerX) * Math.tan(radian);
    let slopeBotRightY = (diffLRight - S/2 - rightX - innerX) * Math.tan(radian);
    let slopeTopRightY = slopeBotLeftY;
    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B/2 - diffLLeft, D/2);
    let leftMidBotLeftPnt = new Point(-B/2 - diffLLeft, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffB, leftMidBotLeftPnt.y + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(-B + diffB, d/2 - h - delta - slopeTopLeftY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - h - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2 - h);
    let rightTopPnt = new Point(0, d/2 - h);

    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffB, rightMidTopRightPnt.y - slopeTopRightY);
    let rightMidBotLeftPnt = new Point(-diffB, leftMidBotLeftPnt.y + slopeBotRightY);
    let rightMidBotRightPnt = new Point(-B/2 + diffLRight, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y - leftY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + leftX, leftMidBotLeftPnt.y);

    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y);
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt3 = new Point(leftMidBotRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidBotRightPntArcCenter.y - innerR * Math.sin(radian1));

    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y);
    let leftMidTopRightPnt3 = new Point(leftMidTopRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidTopRightPntArcCenter.y + innerR * Math.sin(radian1));

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y);
    let rightMidBotLeftPnt3 = new Point(rightMidBotLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidBotLeftPntArcCenter.y - innerR * Math.sin(radian1));

    let rightMidTopLeftPntArcCenter = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y);
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt3 = new Point(rightMidTopLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidTopLeftPntArcCenter.y + innerR * Math.sin(radian1));

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidBotRightPnt1, secondPoint: leftMidBotRightPnt2, thirdPoint: leftMidBotRightPnt3});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidTopRightPnt1, secondPoint: leftMidTopRightPnt2, thirdPoint: leftMidTopRightPnt3});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidTopLeftPnt1, secondPoint: rightMidTopLeftPnt2, thirdPoint: rightMidTopLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidBotLeftPnt1, secondPoint: rightMidBotLeftPnt2, thirdPoint: rightMidBotLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  /*孔板轮*/
  async createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, dis, numHole, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let B = parseFloat(solidWheel.B);
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let delta = 0.005 * d + 3;
    let R1 = D1 / 2;
    let holeD = (d - D1) / 2 - h - delta - S;
    let holeR = holeD / 2;

    let point1 = new Point(-B/2 - S/2, R1 + S/2 + holeR);
    let point2 = new Point(-B/2 - S/2, R1 + S/2 + holeD + 0.1*S);
    let point3 = new Point(-B/2, R1 + S/2 + holeD);
    let point4 = new Point(-B/2 + S/2, point2.y);
    let point5 = new Point(-B/2 + S/2, point1.y);


    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createArcByThreePoint({firstPoint: point2, secondPoint: point4, thirdPoint: point3});
    sketch.createSketchLine({startPoint: point4, endPoint: point5});
    sketch.createSketchLine({startPoint: point5, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  async createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, dis, numHole, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let B = parseFloat(solidWheel.B);
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let delta = 0.005 * d + 3;
    let S1 = 1.5 * S;
    let S2 = 0.5 * S;
    let R = D / 2;
    let R1 = D1 / 2;
    let diffDeltaD1 = (d - D1) / 2 - delta - h;
    let halfDiffDeltaD1R = R1 + diffDeltaD1 / 2;

    let radian = Math.asin((S1 / 2) / halfDiffDeltaD1R);
    let radian1 = 2 * radian;
    let radian2 = 2 * Math.PI - 6 * radian1;
    let radian3 = radian2 / 6;
    let holeR = halfDiffDeltaD1R * Math.sin(radian3 / 2);
    let holeD = 2 * holeR;

    let currentS2 = halfDiffDeltaD1R - R1 - holeR;
    let i = 1;
    while(currentS2 < S2) {
      S1 = (1.5 + i / 10) * S;
      radian = Math.asin((S1 / 2) / halfDiffDeltaD1R);
      radian1 = 2 * radian;
      radian2 = 2 * Math.PI - 6 * radian1;
      radian3 = radian2 / 6;
      holeR = halfDiffDeltaD1R * Math.sin(radian3 / 2);
      holeD = 2 * holeR;
      currentS2 = halfDiffDeltaD1R - R1 - holeR
      i++;
    }

    let pnt1 = new Point(-B/2 - S/2, halfDiffDeltaD1R);
    let pnt2 = new Point(-B/2 - S/2, halfDiffDeltaD1R + holeR + 0.1*S);
    let pnt3 = new Point(-B/2, halfDiffDeltaD1R + holeR);
    let pnt4 = new Point(-B/2 + S/2, pnt2.y);
    let pnt5 = new Point(-B/2 + S/2, pnt1.y);

    let point1 = new Point(dis + pnt1.y, pnt1.x);
    let point2 = new Point(dis + pnt2.y, pnt2.x);
    let point3 = new Point(dis + pnt3.y, pnt3.x);
    let point4 = new Point(dis + pnt4.y, pnt4.x);
    let point5 = new Point(dis + pnt5.y, pnt5.x);

    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createArcByThreePoint({firstPoint: point2, secondPoint: point4, thirdPoint: point3});
    sketch.createSketchLine({startPoint: point4, endPoint: point5});
    sketch.createSketchLine({startPoint: point5, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  /*四、六椭圆辐轮*/
  //L>B
  async createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b = beltDriveParams.beltWidth;
    let P = beltDriveParams.P;
    let m = numHole;
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let delta = 0.005 * d + 3;
    let diff = L - B;
    let hollowY = (d - D1) / 2 - h - delta;
    let solidBotY = ((D1 - D) / 2);

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let a = 0.4 * h1;
    let a2 = 0.8 * a;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let diffBA1 = (B - a) / 2;
    let diffBA2 = (B - a2) / 2;

    let diffLA1 = (L - a) / 2;

    let diffTop = (B - a) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.25 * solidBotY;
    let rightY = 0.25 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let innerX = 0.1 * diffTop;
    let innerY = 0.1 * diffTop;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = diffBA1 * Math.tan(radian);
    let diffSlopeBotLeftY = f1 - slopeBotLeftY;
    let slopeBotRightY = (L - diffBA1 - a - rightX) * Math.tan(radian);
    let diffSlopeBotRightY = f1 - slopeBotRightY;

    let slopeTopY = diffBA2 * Math.tan(radian);
    let diffSlopeTopY = f2 - slopeTopY;

    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B, D/2);
    let leftMidBotLeftPnt = new Point(-B, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffBA1, D1/2 + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(-B + diffBA2, d/2 - h - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - h - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2 - h);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffBA2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(-diffBA1, D1/2 + slopeBotRightY);
    let rightMidBotRightPnt = new Point(diff, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);

    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - diffSlopeBotLeftY * Math.cos(radian), leftMidBotRightPnt.y - diffSlopeBotLeftY * Math.sin(radian));
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + diffSlopeBotLeftY);
    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt1.x, leftMidBotRightPnt1.y + diffSlopeBotLeftY);

    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - diffSlopeTopY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - diffSlopeTopY * Math.cos(radian), leftMidTopRightPnt.y + diffSlopeTopY * Math.sin(radian));
    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt2.x, leftMidTopRightPnt2.y - diffSlopeTopY);

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + diffSlopeBotRightY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + diffSlopeBotRightY * Math.cos(radian), rightMidBotLeftPnt.y - diffSlopeBotRightY * Math.sin(radian));
    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt2.x, rightMidBotLeftPnt2.y + diffSlopeBotRightY);

    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + diffSlopeTopY * Math.cos(radian), rightMidTopleftPnt.y + diffSlopeTopY * Math.sin(radian));
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - diffSlopeTopY);
    let rightMidTopLeftPntArcCenter = new Point(rightMidTopLeftPnt1.x, rightMidTopLeftPnt1.y - diffSlopeTopY);

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt, endPoint: leftMidBotRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidBotRightPntArcCenter, startPoint: leftMidBotRightPnt1, endPoint: leftMidBotRightPnt2});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidTopRightPntArcCenter, startPoint: leftMidTopRightPnt1, endPoint: leftMidTopRightPnt2});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidTopLeftPntArcCenter, startPoint: rightMidTopLeftPnt1, endPoint: rightMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidBotLeftPntArcCenter, startPoint: rightMidBotLeftPnt1, endPoint: rightMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let b =beltDriveParams.beltWidth;
    let P = beltDriveParams.P;
    let m = numHole;
    let d = parseFloat(solidWheel.d);
    let h = parseFloat(solidWheel.h);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let delta = 0.005 * d + 3;

    let solidBotY = ((D1 - D) / 2);
    let leftL = 0.35 * L;
    let rightL = 0.65 * L;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let a = 0.4 * h1;
    let a2 = 0.8 * a;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let diffBA1 = (B - a) / 2;
    let diffBA2 = (B - a2) / 2;

    let diffTop = (B - a) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let midBotX = 0.05 * solidBotY;
    let midBotY = 0.05 * solidBotY;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = (leftL - midBotX - a/2) * Math.tan(radian);
    let diffSlopeBotLeftY = f1 - slopeBotLeftY;
    let slopeBotRightY = (rightL - rightX - a/2) * Math.tan(radian);
    let diffSlopeBotRightY = f1 - slopeBotRightY;

    let slopeTopY = diffBA2 * Math.tan(radian);
    let diffSlopeTopY = f2 - slopeTopY;

    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B/2 - leftL, D/2);
    let leftMidBotLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffBA1, D1/2 + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(-B + diffBA2, d/2 - h - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - h - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2 - h);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffBA2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(-diffBA1, D1/2 + slopeBotRightY);
    let rightMidBotRightPnt = new Point(-B/2 + rightL, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);
    //弧
    let arcInfo = beltDriveModelCommand.calculateCenterRadiusRadian(leftTopPnt, topMidLeftPnt, rightTopPnt);
    console.log('arcInfo' + arcInfo);
    let arcLength = (b - l) / 2;
    this.calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength);

    let halfLineRadian = Math.asin((l / 2) / arcInfo.radius);
    let topDiffY = arcInfo.radius - arcInfo.radius * Math.cos(halfLineRadian);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y  - midBotY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + midBotX, leftMidBotLeftPnt.y);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - diffSlopeBotLeftY * Math.cos(radian), leftMidBotRightPnt.y - diffSlopeBotLeftY * Math.sin(radian));
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + diffSlopeBotLeftY);
    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt1.x, leftMidBotRightPnt1.y + diffSlopeBotLeftY);

    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - diffSlopeTopY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - diffSlopeTopY * Math.cos(radian), leftMidTopRightPnt.y + diffSlopeTopY * Math.sin(radian));
    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt2.x, leftMidTopRightPnt2.y - diffSlopeTopY);

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + diffSlopeBotRightY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + diffSlopeBotRightY * Math.cos(radian), rightMidBotLeftPnt.y - diffSlopeBotRightY * Math.sin(radian));
    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt2.x, rightMidBotLeftPnt2.y + diffSlopeBotRightY);

    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + diffSlopeTopY * Math.cos(radian), rightMidTopleftPnt.y + diffSlopeTopY * Math.sin(radian));
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - diffSlopeTopY);
    let rightMidTopLeftPntArcCenter = new Point(rightMidTopLeftPnt1.x, rightMidTopLeftPnt1.y - diffSlopeTopY);

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidBotRightPntArcCenter, startPoint: leftMidBotRightPnt1, endPoint: leftMidBotRightPnt2});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidTopRightPntArcCenter, startPoint: leftMidTopRightPnt1, endPoint: leftMidTopRightPnt2});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: topMidLeftPnt, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: topMidLeftPnt, endPoint: topMidRightPnt});
    sketch.createArcByCenter({centerPoint: arcInfo.centerPoint, startPoint: rightTopPnt, endPoint: topMidRightPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidTopLeftPntArcCenter, startPoint: rightMidTopLeftPnt1, endPoint: rightMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidBotLeftPntArcCenter, startPoint: rightMidBotLeftPnt1, endPoint: rightMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //90°扇形草图
  async createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, dis, n, numHole, no) {
    let sketch = this.command.sketch;

    let d = parseFloat(solidWheel.d);
    let radian = 2 * Math.PI / numHole;
    let P = beltDriveParams.P;
    let m = numHole;
    let h = parseFloat(solidWheel.h);
    let D1 = parseFloat(solidWheel.D1);
    let delta = 0.005 * d + 3;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let w1 = h1 / 2;
    let w2 = h2 / 2;

    let innerR = D1 / 2 + f1;
    let outerR = d / 2 - h - delta - f2;
    let diffR = outerR - innerR;

    //圆心
    let centerPnt = new Point(parseFloat(dis), 0);

    //下弧
    let height = Math.sqrt(Math.pow(outerR, 2) - Math.pow(w2, 2));
    let botLeftPnt1 = new Point(centerPnt.x + w1, 0);
    let botLeftPnt2 = new Point(centerPnt.x + w2, height);
    let botLeftPnt = beltDriveModelCommand.calculateIntersection(botLeftPnt1, botLeftPnt2, centerPnt, innerR, true);
    if(!botLeftPnt) {
      return null;
    }

    let botRightPnt1 = new Point(centerPnt.x + 0, w1);
    let botRightPnt2 = new Point(centerPnt.x + height, w2);
    let botRightPnt = beltDriveModelCommand.calculateIntersection(botRightPnt1, botRightPnt2, centerPnt, innerR, false);
    if(!botRightPnt) {
      return null;
    }

    //左弧
    let leftPnt1 = botLeftPnt2;

    //右弧
    let rightPnt1 = botRightPnt2;

    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: 8});
    sketch.createArcByCenter({centerPoint: centerPnt, startPoint: botRightPnt, endPoint: botLeftPnt});
    sketch.createSketchLine({startPoint: botLeftPnt, endPoint: leftPnt1});
    sketch.createArcByCenter({centerPoint: centerPnt, startPoint: rightPnt1, endPoint: leftPnt1});
    sketch.createSketchLine({startPoint: rightPnt1, endPoint: botRightPnt});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      //编辑扇形草图圆角
      await this.editSixOvalSpokeWheelSectorSketch(sketchFeature, diffR);
      return sketchFeature;
    }
  }
  //60°扇形草图
  async createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, dis, n, numHole, no) {
    let sketch = this.command.sketch;

    let d = parseFloat(solidWheel.d);
    let radian = 2 * Math.PI / numHole;
    let P = beltDriveParams.P;
    let m = numHole;
    let h = parseFloat(solidWheel.h);
    let D1 = parseFloat(solidWheel.D1);
    let delta = 0.005 * d + 3;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;
    let w1 = h1 / 2;
    let w2 = h2 / 2;

    let innerR = D1 / 2 + f1;
    let outerR = d / 2 - h - delta - f2;
    let diffR = outerR - innerR;

    //圆心
    let centerPnt = new Point(parseFloat(dis), 0);
    //下弧
    let oPnt = new Point(centerPnt.x + w1,  centerPnt.y + w1 * Math.tan(radian));
    let botPnt1x = centerPnt.x + innerR * Math.cos((Math.PI / 2) - (radian / 2));
    let botPnt1y = centerPnt.y + innerR * Math.sin((Math.PI / 2) - (radian / 2));
    let offsX1 = botPnt1x - centerPnt.x - w1;

    let i = 1;
    while(offsX1 <= 0) {
      f1 = (0.2 + i / 10) * h1;
      innerR = D1 / 2 + f1;
      botPnt1x = centerPnt.x + innerR * Math.cos((Math.PI / 2) - (radian / 2));
      botPnt1y = centerPnt.y + innerR * Math.sin((Math.PI / 2) - (radian / 2));
      offsX1 = botPnt1x - centerPnt.x - w1;
      i++;
    }

    let offsY1 = offsX1 * Math.tan(radian);
    let botPnt2x = botPnt1x - offsX1;
    let botPnt2y = botPnt1y + offsY1;
    let distance1 = Math.sqrt(Math.pow((botPnt2x - oPnt.x), 2) + Math.pow((botPnt2y - oPnt.y), 2));
    let botPnt3x = oPnt.x + distance1 * Math.cos(Math.PI / 6);
    let botPnt3y = oPnt.y + distance1 * Math.sin(Math.PI / 6);
    let botPnt1 = new Point(botPnt1x, botPnt1y);
    let botPnt2 = new Point(botPnt2x, botPnt2y);
    let botPnt3 = new Point(botPnt3x, botPnt3y);

    //上弧
    let topPnt1x = centerPnt.x + outerR * Math.cos((Math.PI / 2) - (radian / 2));
    let topPnt1y = centerPnt.y + outerR * Math.sin((Math.PI / 2) - (radian / 2));
    let topPnt1 = new Point(topPnt1x, topPnt1y);

    //左弧
    let radian1 = Math.asin(w2 / outerR);
    let offsY2 = outerR * Math.cos(radian1);
    let leftPnt1x = centerPnt.x + w2;
    let leftPnt1y = centerPnt.y + offsY2;
    let leftPnt1 = new Point(leftPnt1x, leftPnt1y);

    //右弧
    let radian2 = (Math.PI / 2) - radian + radian1;
    let offsX3 = outerR * Math.cos(radian2);
    let offsY3 = outerR * Math.sin(radian2);
    let rightPnt1x = centerPnt.x + offsX3;
    let rightPnt1y = centerPnt.y + offsY3;
    let rightPnt1 = new Point(rightPnt1x, rightPnt1y);

    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: 8});
    sketch.createArcByThreePoint({firstPoint: botPnt2, secondPoint: botPnt3, thirdPoint: botPnt1});
    sketch.createSketchLine({startPoint: botPnt2, endPoint: leftPnt1});
    sketch.createArcByThreePoint({firstPoint: leftPnt1, secondPoint: rightPnt1, thirdPoint: topPnt1});
    sketch.createSketchLine({startPoint: rightPnt1, endPoint: botPnt3});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      //编辑扇形草图圆角
      await this.editSixOvalSpokeWheelSectorSketch(sketchFeature, diffR);
      return sketchFeature;
    }
  }
  // 编辑扇形草图
  async editSixOvalSpokeWheelSectorSketch(sketchFeature, diameter) {
    if (!sketchFeature) {
      return;
    }
    let elements = await beltDriveModelCommand.getElementsByFeature(this.query, sketchFeature);
    let sketch = this.command.sketch;
    if(elements?.length > 3) {
      sketch.editSketch({sketchName: sketchFeature.name});
      sketch.createFilletCurve({curveId1:elements[1].id, curveId2:elements[2].id, radius: parseFloat(diameter) * 0.1});
      sketch.createFilletCurve({curveId1:elements[2].id, curveId2:elements[3].id, radius: parseFloat(diameter) * 0.1});
      sketch.exitEditSketch({sketchName: sketchFeature.name});
      await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
    }
  }
  /**************************************************
   * 平带传动实现函数End
   * *************************************************/
  calculateArcPoints(arcInfo, topMidLeftPnt, topMidRightPnt, arcLength){
    let centerPoint = arcInfo.centerPoint;
    let r = arcInfo.radius;
    let point1 = topMidLeftPnt;
    let point2 = centerPoint;
    let point3 = new Point(centerPoint.x + r, centerPoint.y);
    let point4 = centerPoint;
    let radian = beltDriveModelCommand.calculateRadianBetweenTwoVectors(point1, point2, point3, point4);
    let radian1 = arcLength / r;
    let radian2 = radian + radian1;
    let radian3 = radian + radian1/2;
    let radian4 = Math.PI - radian - radian1/2;
    let radian5 = Math.PI - radian - radian1;
    let arcPoint1 = new Point(centerPoint.x + r * Math.cos(radian2), centerPoint.y + r * Math.sin(radian2));
    let arcPoint2 = new Point(centerPoint.x + r * Math.cos(radian3), centerPoint.y + r * Math.sin(radian3));
    let arcPoint3 = new Point(centerPoint.x + r * Math.cos(radian4), centerPoint.y + r * Math.sin(radian4));
    let arcPoint4 = new Point(centerPoint.x + r * Math.cos(radian5), centerPoint.y + r * Math.sin(radian5));
    let drivingPoints = [];
    //let radian4 =  this.radian - Math.PI / 2;
    let radian6 =  0;
    let drivingPoint1 = new Point(arcPoint1.x, arcPoint1.y * Math.cos(radian6));
    let drivingPoint2 = new Point(arcPoint2.x, arcPoint2.y * Math.cos(radian6));
    let drivingPoint3 = new Point(topMidLeftPnt.x, topMidLeftPnt.y * Math.cos(radian6));
    let drivingPoint4 = new Point(topMidRightPnt.x, topMidRightPnt.y * Math.cos(radian6));
    let drivingPoint5 = new Point(arcPoint3.x, arcPoint3.y * Math.cos(radian6));
    let drivingPoint6 = new Point(arcPoint4.x, arcPoint4.y * Math.cos(radian6));
    let drivingCenterPoint = new Point(centerPoint.x, centerPoint.y * Math.cos(radian6));
    
    drivingPoints.push(drivingPoint1);
    drivingPoints.push(drivingPoint2);
    drivingPoints.push(drivingPoint3);
    drivingPoints.push(drivingPoint4);
    drivingPoints.push(drivingPoint5);
    drivingPoints.push(drivingPoint6);
    let arc = {
      Points: drivingPoints,
      Center: drivingCenterPoint,
      Radius: arcInfo.radius
    }
    this.beltPointList.push(arc);
    
  }
}

const flatBeltDriveCommand = new FlatBeltDriveCommand();
export {flatBeltDriveCommand};
